source("DHMM_markov.R")
hmm=initDHMM(States=c("1","2"), Symbols=c("A","C", "T","G"), duration=list(1:5,1:10),
	      emisProbs=matrix(c(.4,.1,.4,.1,.1,.4,.1,.4),nrow=2),
	      emisMarkovProbs=list(
		matrix(c(0.7, 0.1, 0.7, 0.1, 0.1, 0.7, 0.1, 0.7, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1), nrow=4 ),
		matrix(c(0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.7, 0.1, 0.7, 0.1, 0.1, 0.7, 0.1, 0.7), nrow=4 )
	      )
            )

for (state in 1:length(hmm$States))
  dimnames(hmm$emissionMarkovProbs[[state]]) = list(from=hmm$Symbols,to=hmm$Symbols)

print(hmm)
#simulation
res=simHMM(hmm,10)
print(res)
#forward
#lForwardProbs=forward(hmm,res$observation)
#print(exp(lForwardProbs))
a=check_fb(hmm, res$observation)
print(c("a=",a))

trHMM=baumWelch(hmm, res$observation)
print(trHMM)